/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_adjust_luck_or_morale.cpp

	$Header: /heroes4/script_adjust_luck_or_morale.cpp $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "army.h"
#include "basic_dialog.h"
#include "creature_array.h"
#include "hero.h"
#include "town.h"
#include "script_adjust_luck_or_morale.h"
#include "script_targeting.h"

static bool g_adjusted_attribute;

bool t_script_adjust_attribute::read_from_map(std::streambuf &	stream,	int	format_version )
{
	if ( !t_script_stack_adjustment_action< t_uint8 >::read_from_map( stream, format_version ) )
		return false;

	m_adjustment *= m_direction;

	return true;
}

void t_script_adjust_attribute::add_icons(t_basic_dialog* dialog) const
{
	if (g_adjusted_attribute) {
		if (m_attribute == k_stat_luck) 
			dialog->add_luck(get_adjustment());
		else
			dialog->add_morale(get_adjustment());
	}
}

void t_script_adjust_attribute::make_adjustment(t_creature_stack* stack) const
{
	if (g_adjusted_attribute = (stack != 0))
		stack->add_bonus(m_attribute, get_adjustment());	
}

void t_script_adjust_attribute::make_adjustment(t_creature_array* array) const
{
	if (g_adjusted_attribute = (array != 0))
		array->add_bonus(m_attribute, get_adjustment());
}


